package com.ruoyi.ssm0115;

import com.ruoyi.ssm0115.Student;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

// 前端ApiFox ——请求——> SpringMVC框架(接受前端的数据)

// 前端ApiFox <——响应—— SpringMVC框架(响应的数据方式)

@RestController
@RequestMapping("/student")
public class StudentController {

    @RequestMapping("/m1")
    public String m1(@RequestParam("a") String name, @RequestParam("b") int age) {
        System.out.println(name);
        System.out.println(age);
        return "m1";
    }

    @RequestMapping("/m2")
    public String m2(Student student) {
        System.out.println(student);
        return "m2";
    }

    @RequestMapping("/m3")
    public Student m3() {
        Student s = new Student();
        s.setName("张三");
        s.setAge(18);
        return s;
    }

    @RequestMapping("/m4")
    public List<Student> m4() {
        List<Student> list = new ArrayList<>();
        Student s1 = new Student();
        s1.setName("张三");
        s1.setAge(18);
        Student s2 = new Student();
        s2.setName("李四");
        s2.setAge(40);
        list.add(s1);
        list.add(s2);
        return list;
    }

}